package LC;

/**
 * @ClassName LC12
 * @Description: TODO
 * @Author hl
 * @Date 2021/3/27
 * @Version V1.0
 **/
public class LC12 {
    public static String intToRoman(int num) {
        String[] charArr={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
        int [] numArr={1000,900,500,400,100,90,50,40,10,9,5,4,1};
        StringBuilder res=new StringBuilder();
        for(int  i=0;i<numArr.length;i++){
            while(num>=numArr[i]){
                res.append(charArr[i]);
                num=num-numArr[i];
            }
        }
        return res.toString();
    }

    public static void main(String[] args) {
        System.out.println(intToRoman(15));
    }
}
